<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            text-align: center;
        }
        #box1{
            width: 100px;
            height: 100px;
            background-color: black;
            margin: auto;
            margin-top: 40px;
        }
    </style>
</head>
<body>
    <div class="box">
        <button onclick="c_width()">变宽</button>
        <button onclick="c_height()">变高</button>
        <button onclick="c_color()">变色</button>
        <button onclick="c_hide()">隐藏</button>
        <button onclick="c_block()">显现</button>
        <button onclick="c_reset()">重置</button>
        <div id="box1"></div>
    </div>
</body>
</html>


<script>
    var hz = document.getElementById('box1')
    function c_width(){
        hz.style.width = "200px"
    }
    function c_height(){
        hz.style.height = "200px"
    }
    function c_color(){
        hz.style.background = "darkred"
    }
    function c_hide(){
        hz.style.display = "none"
    }
    function c_block(){
        hz.style.display = "block"
    }
    function c_reset(){
        // cssText 可以多写入样式
        hz.style.cssText = "background:black; width:100px;height:100px"
    }
</script>